package com.platform.modules.demo.controller;

import com.platform.dto.MessageSendDto;
import com.platform.entity.SysMessageEntity;
import com.platform.entity.SysMsgReceiverEntity;
import com.platform.modules.mail.service.MailService;
import com.platform.modules.quality.vo.CommonResult;
import com.platform.service.MessageHandleService;
import com.platform.service.MessageService;
import com.platform.service.impl.JPushService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api("jpush")
@RestController
@RequestMapping("jpush")
public class JPushController {

    @Resource(name = "jPushService")
    private JPushService jPushService;

    @Resource(name = "jPushService")
    private MessageService messageService;
    
    @Autowired
    private MessageHandleService messageHandleService;



    @GetMapping("/push")
    public CommonResult push(String userId){

        SysMessageEntity entity = new SysMessageEntity();
        entity.setClientId("smartcs");
        entity.setTitle("12121");
        entity.setContent("121212");
        List<SysMsgReceiverEntity> receivers =
                Arrays.asList(
                        new SysMsgReceiverEntity("0d68750a3e052fb64d93d8ca9cc3bb3d","0d68750a3e052fb64d93d8ca9cc3bb3d")


        );

        jPushService.send(entity,Arrays.asList(),receivers);
        return CommonResult.success();
    }
    

    @GetMapping("/test")
    public CommonResult test(){
    	MessageSendDto messageSendDto = new MessageSendDto();
    	messageSendDto.setClientId("smartcs");
    	messageSendDto.setSaveFlag(true);
    	messageSendDto.setTemplateCode("ZLXC_GQFZR");
    	messageSendDto.setUserId("0d68750a3e052fb64d93d8ca9cc3bb3d");
    	messageSendDto.setUserThirdId("0d68750a3e052fb64d93d8ca9cc3bb3d");
    	Map<String, String> extend = new HashMap();
    	extend.put("ag1", "参数1");
    	
    	messageSendDto.setExtend(extend);
    	
    	messageHandleService.send(messageSendDto);

        return CommonResult.success();
    }
    

}
